#pragma once

#include "UI\Widgets\Widget.h"

namespace ShRp
{
	namespace UI
	{
		class Control
		{
		public:
			struct Type
			{
				enum E
				{
					Control,
					SimpleControl
				};
			};

		public:
			static bool StaticInit();
			virtual bool Init(int2 _Pos, int2 _Size);
			virtual void Terminate();

			virtual void Move(int2 _NewPos);
			virtual void Resize(int2 _NewSize);

			HWND GetHWND()		const	{	return m_HWND;	}
			Type::E GetType()	const	{	return m_Type;	}

			int2 GetPos()		const	{	return m_Pos;	}
			int2 GetSize()		const	{	return m_Size;	}

			void AddChild( Widget* _Widget );
		protected:
			void CreateHWND();
			void HandleMessage(WindowsMessage::E _Message, ...);

			virtual void Paint() = 0;

			HWND m_HWND;
			int2 m_Pos, m_Size;
			const Type::E m_Type;


			// Only the ControlMgr & Factory can access the constructor.
			friend class ShRp::UI::ControlMgr;
			friend class ShRp::UI::ControlFactory;
			Control(Type::E _Type);
			Control(const Control& _Window)
				: m_Type(_Window.GetType())
			{
				Error("Control copy constructor should not be used.\n");
			}
			Control()
				: m_Type(Control::Type::Control)
			{
				Error("Control default constructor should not be used.\n");
			}
			virtual void MouseMove()						{}
			virtual void MouseDown( MouseButton::E _Btn )	{}
			virtual void MouseUp( MouseButton::E _Btn )		{}
			virtual void KeyDown( Key::En _Key )			{}
			virtual void KeyRepeat( Key::En _Key )			{}
			virtual void KeyUp( Key::En _Key )				{}

			WidgetVector m_Children;
		};
		typedef std::list<Control*> ControlList;
		typedef std::vector<Control*> ControlVector;
	};
};